import Koa from 'koa'
import InitManager from './src/utils/init.js'
import koaBody from 'koa-body'
import cors from '@koa/cors'
import errorHandler from './src/middlewares/errorHandler.js'

import config from './src/config/index.js'

// import { WebSocketServer } from 'ws'

const app = new Koa()

// Middlewares
app.use(cors())
app.use(koaBody({ multipart: true }))
app.use(errorHandler)

const port = config.port

InitManager.initCore(app)

app.listen(port, () => {
  console.log(`Server is running on port ${port}`)
})

import ws from './src/utils/ws.js'
ws.run()
